package demo;

public class Student {
    private int age = 0;
    public String name = "-";
    private double score = 0.0;
    public static String schoolName = "大学";//就地初始化

    //实例化代码块
    {
        this.name = "张三";
        this.age = 18;
        this.score = 100;
        System.out.println("调用了实例化代码块！");
    }
    //静态代码块
    static {
        schoolName = "xx大学";
        System.out.println("调用了静态代码块！");
    }

    public Student(int age, String name, double score) {
        this.age = age;
        this.name = name;
        this.score = score;
        System.out.println("调用含参构造方法！");
    }
    public Student() {
        System.out.println("调用无参构造方法！");
    }
    public static String study() {
        return "正在在"+Student.schoolName+"上课！";
    }
}
